﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace KPIS.GERP.WCF.ePayment
{
    public static class ExceptionHandler
    {
        public static void GetException(ExceptionCode exceptionCode)
        {
            GetException(exceptionCode, "");
        }

        public static void GetException(ExceptionCode exceptionCode, string addDetail)
        {
            switch (exceptionCode)
            {
                case ExceptionCode.E_Random:
                    throw new Exception("E_Random", new Exception("A random exception for test."));
                case ExceptionCode.E_TransactionId:
                    throw new Exception("E_TransactionId", new Exception("A transaction ID could not be found."));
               
                case ExceptionCode.E_ArgumentsValidation:
                    throw new Exception("E_ArgumentsValidation", new Exception(string.Format("The Argument(s) validation error. [{0}]", addDetail)));
                case ExceptionCode.E_DuplicateInvoice:
                    throw new Exception("E_DuplicateInvoice", new Exception(string.Format("The invoice code is already added. [{0}]", addDetail)));
                case ExceptionCode.E_InvalidProcess:
                    throw new Exception("E_InvalidProcess", new Exception("A Process name could not be found."));
                case ExceptionCode.E_InvalidSupplier:
                    throw new Exception("E_InvalidSupplier", new Exception(string.Format("The supplier tax code could not be found. [{0}]", addDetail)));
                case ExceptionCode.E_IncorrectDate:
                    throw new Exception("E_IncorrectDate", new Exception("The date is invalid or incorrect format."));
                case ExceptionCode.E_IncorrectNumeric:
                    throw new Exception("E_IncorrectNumeric", new Exception("The number is invalid or incorrect format."));
                default:
                    throw new Exception();
            }
        }
    }

    public enum ExceptionCode
    {
        E_Random,
        E_TransactionId,

        E_InvalidProcess,
        E_InvalidSupplier,

        E_IncorrectDate,
        E_IncorrectNumeric,

        E_ArgumentsValidation,
        E_DuplicateInvoice,
    }
}